var mysql = require('mysql');

var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '985423691458',
    database: 'juzao',
    multipleStatements:true
});


module.exports = (sql) => {
    return new Promise(next => {
        connection.connect((err)=>{
            if (err) console.log(err)
        });
        connection.query(sql, function (error, results, fields) {
            if (error) console.log(error)
            next(results)
        });
        // connection.end((err)=>{
        //     if (err) console.log(err)
        //     console.log('成功关闭')
        // });
    })
}



